'''
Created on 2012-6-12

@author: wb_suoyao.shen
'''
from django.http import HttpResponse
from django.core import serializers
from django.shortcuts import render_to_response
from ssyblog.photos.models import Album
from ssyblog.photos.models import Photos

def photos(request):
    album_preview_list = Album.objects.queryAlbumPreview()
    return render_to_response('photos_waterfall.html',locals())

def loadPhotos(request,albumId,page):
    if albumId:
        photos_list = Photos.objects.queryPhotosByPage(albumId, int(page)*10)
        if len(list(photos_list)) > 0:
            return HttpResponse(serializers.serialize('json', photos_list),mimetype='application/json')
        else:
            return HttpResponse(serializers.serialize('json', []),mimetype='application/json')
    else:
        return HttpResponse()